<template>
	<view class="nav-bar">
		<view class="box">
			<view class="state-bar" :style="{height:statusBarHeight + 'px'}">

			</view>
			<view class="title-bar" :style="{height:titleBarHeight + 'px'}">
				<view class="title">
					{{ title }}
				</view>
				<view class="search" @click="handleNavTo">
					<uni-icons type="search"></uni-icons>
					<text>搜索</text>
				</view>
			</view>
		</view>
		<view class="fill" :style="{height:navBarHeight + 'px'}">

		</view>
	</view>
</template>

<script setup>
	import {
		useSystemInfo
	} from '@/utils/system.js'

	const {
		statusBarHeight,
		titleBarHeight,
		navBarHeight
	} = useSystemInfo()

	defineProps({
		title: {
			type: String,
			default: () => {
				return ''
			}
		}
	})

	// 打开搜索界面
	const handleNavTo = () => {
		uni.navigateTo({
			url: '/pages/search/search'
		})
	}
</script>

<style lang="scss" scoped>
	.nav-bar {
		.box {
			position: fixed;
			left: 0;
			top: 0;
			width: 100%;
			z-index: 10;
			background:
				linear-gradient(to bottom, transparent, #fff 400rpx),
				linear-gradient(to right, #64b3f4 20%, #c2e59c);

			.title-bar {
				display: flex;
				align-items: center;
				padding: 0 30rpx;

				.title {
					font-size: 36rpx;
					font-weight: 700;
					color: $text-color;
				}

				.search {
					width: 220rpx;
					height: 50rpx;
					padding: 0 10rpx;
					border-radius: 60rpx;
					background: rgba(255, 255, 255, .3);
					border: 1rpx solid #fff;
					margin-left: 30rpx;
					color: $text-assist-color;
					font-size: 28rpx;
					display: flex;
					align-items: center;
				}
			}
		}
	}
</style>